package de.eeb.common;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


public class SBPayment {
	private String id;
	private Double amount;
	private String description;
	private Date date;
	private boolean closed;
	private String buyer;
	private List<String> participants = new ArrayList<String>();

	public SBPayment(String id) {
		super();
		this.id = id;
	}
	
	
	
	public String getBuyer() {
		return buyer;
	}



	public void setBuyer(String buyer) {
		this.buyer = buyer;
	}



	public SBPayment(String buyer, String id, Double amount, String description, Date date,
			boolean closed, List<String> participants) {
		super();
		this.id = id;
		this.amount = amount;
		this.description = description;
		this.date = date;
		this.closed = closed;
		this.participants = participants;
		this.buyer = buyer;
	}
	
	@Override
	public String toString() {
		return "SBPayment [id=" + id + "]";
	}
        
        public Double getEachDebt() {
            return amount / (participants.size() + 1);
        }

	public List<String> getParticipants() {
		return participants;
	}
	public void setParticipants(List<String> participants) {
		this.participants = participants;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public Double getAmount() {
		return amount;
	}
	public void setAmount(Double amount) {
		this.amount = amount;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public boolean isClosed() {
		return closed;
	}
	public void setClosed(boolean closed) {
		this.closed = closed;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SBPayment other = (SBPayment) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}	
}
